<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>个人信息</title>

    <link rel="stylesheet" th:href="@{layui/css/layui.css}">
    <link rel="stylesheet" th:href="@{layui/css/bootstrap.css}">
    <link rel="stylesheet" th:href="@{layui/css/personal.css}">

</head>
<body>
<section class="layui-larry-box">
    <div class="larry-personal">
        <blockquote class="layui-elem-quote layui-text">
            <!--<header class="larry-personal-tit">-->
                <span>我的课程</span>
            <!--</header>&lt;!&ndash; /header &ndash;&gt;-->
        </blockquote>
        <form class="layui-form col-lg-5 " action="" method="post">

            <div class="layui-form-item">
                <label class="layui-form-label">课程号</label>
                <div class="layui-input-block">
                    <input type="text" name="teachclassno"  autocomplete="off" class="layui-input"   th:value="${lesson.teachclassno}">
                </div>
            </div>
            <input type="hidden" name="id" th:value="${lesson.id}" >
            <div class="layui-form-item">
                <label class="layui-form-label">课程名</label>
                <div class="layui-input-block">
                    <input type="text" name="coursename"  autocomplete="off" class="layui-input" th:value="${lesson.coursename}" >
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">学期</label>
                <div class="layui-input-block">
                    <input type="text" name="coursesemester"  autocomplete="off" class="layui-input"  th:value="${lesson.coursesemester}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">学分</label>
                <div class="layui-input-block">
                    <input type="text" name="credit"  autocomplete="off" class="layui-input" th:value="${lesson.credit}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">方式</label>
                <div class="layui-input-block">
                    <input type="text" name="evalmethod"  autocomplete="off" class="layui-input" th:value="${lesson.evalmethod}">
                </div>
            </div>
            <p  id="hint"  style="color: red" align="center"></p>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button  class="layui-btn" lay-submit lay-filter="formDemo">修改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
        <header class="larry-personal-tit">
        <span>此页面暂不支持修改太多学生信息</span>
        </header><!-- /header -->

        <div class="larry-personal-body clearfix">
            <table class="layui-table" id="demo2" lay-filter="test">
                <thead>
                <tr>
                    <th>学号</th>
                    <th>姓名</th>
                    <th>拼音</th>
                    <th>序号</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="stu:${list}" >
                    <td th:text="${stu['studentno']}" ></td>
                    <td th:text="${stu['name']}"></td>
                    <td th:text="${stu['pinyin']}"></td>
                    <td th:text="${stu['no']}"></td>
                    <td >
                        <a   class="layui-btn layui-btn-xs" th:stuclaid="${stu['ID']}" onclick="funchange(this)">序号修改</a>
                        <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="alertcheckdelete(this)">删除</a></td>
                </tr>
                </tbody>
            </table>
        </div>

    </div>
</section>

<script type="text/javascript" th:src="@{layui/layui.js}"></script>
<script type="text/javascript" th:src="@{layui/jquery-2.2.1.min.js}"></script>
<script type="text/javascript" th:src="@{js/jquery.cookie.js}"></script>
<script type="text/javascript">
    layui.use(['form','upload','layedit','laydate','table'],function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,table=layui.table
            ,laydate = layui.laydate;
        form.on('submit(formDemo)', function(data){
            //执行实例
            layer.confirm('真的进行修改么', function(index){
                $.post("teacher/updatetechclass",data.field,function(res){
                    layer.msg(JSON.stringify(res));
                    $("#hint").html(res);
                });
                layer.close(index);
                //向服务端发送删除指令
            });

            return false;
        });


    });
//从名单上删除这个小孩
    function deleteinfo(obj) {
        var obje=$(obj).attr('stuclaid');
        $.ajax({
            url: "deletebystuclaid",
            type: "POST",
            data: {
                stuclaid:obje
            },
            traditional: true,//这里设置为true
            success: function(data) {
                //do sth...
                layer.msg(JSON.stringify(data));
                console.log(data);
                window.location.reload();
                //alert(data);
            }

        });

    }
    function funchange(obj) {//修改花名册排名
//页面层
        var stuclaid=$(obj).attr('stuclaid');
        $.cookie('stuclaid', stuclaid);

        layer.prompt({
            formType: 3,
            value: '',
            title: '编号',
            area: ['300px', '200px'] //自定义文本域宽高
        }, function (value, index, elem) {

            var data1={
                'stuclaid':$.cookie('stuclaid'),
                'num':value,
            };
            console.log(data1);
            $.post("teacher/updatestuclaid",data1,function(res){
                layer.msg(JSON.stringify(res));

                window.location.reload();
            });
            layer.close(index);
        });

    }
    //真的添加？
    function alertcheckadd(obj) {
        layer.confirm('真的添加课程么', function(index){
            addinfo(obj);
            layer.close(index);
            //向服务端发送删除指令
        });
    }
    //真的删除？
    function alertcheckdelete(obj) {
        layer.confirm('真的删除行么', function(index){
           deleteinfo(obj);
            layer.close(index);
            //向服务端发送删除指令
        });
    }

</script>
</body>
</html>